@extends('admin.layouts.app')
@section('product','active')
@section('pro-type','active')

@section('style')
     <!-- Bootstrap Select Css -->
    <link href="{{asset('admin/plugins/bootstrap-select/css/bootstrap-select.css')}}" rel="stylesheet" />
    <!-- Dropzone Css --> 
    <link href="{{asset('admin/plugins/sweetalert/sweetalert.css')}}" rel="stylesheet" />

@endsection

@section('content')
       
	 <div class="container-fluid">
            <div class="block-header">
                <h2>
                    属性管理
                </h2>
            </div>
            <!-- Basic Table -->
            <div class="row clearfix">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="card">
                        <div class="header">
                            <h2>
                                属性列表
                            </h2>
                            <div class="align-left" style="margin-top:10px;">
                                 <a href="{{route('attributes.create',$id)}}" class="btn btn-primary btn-xs" >
                                        <i class="material-icons">add</i>
                                        <span>添加属性</span>
                                </a>
                            </div>
                        </div>

                        <div class="body table-bordered">
                         <div class="form-group">
                                      <select class="form-control show-tick" style="width: 50%" name="cate_id">
                                        <option value="0">-- 选择商品类型 --</option>
                                        @foreach($types as $type)
                                            <option value="{{$type->id}}" @if($id == $type->id) selected @endif>{{$type->type_name}}</option> 
                                        @endforeach

                                    </select>
                                </div>
                            <table class="table table-bordered table-striped table-hover js-basic-example dataTable">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>属性名称</th>
                                        <th>属性的类型</th>
                                        <th>属性的可选值</th>
                                        <th>所在的商品类型</th> 
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>

                                    @foreach($attrs as $attr)

                                        <tr>
                                            <td scope="row">{{$loop->index+1}}</td>
                                            <td>{{$attr->attr_name}}</td>
                                            <td>@if($attr->attr_type ==0)唯一 @else 可选 @endif</td>
                                            <td>@if(!empty($attr->attr_option_values)){{$attr->attr_option_values}} @else null @endif</td>
                                            <td>
                                            {!! $attr->type->type_name !!} 
                                            </td>
 
                                            <td>

                                                <a href="{{ route('attributes.edit',[$attr->id,$attr->type_id]) }}" class="btn bg-green btn-xs">
                                                    <i class="material-icons">mode_edit</i>
                                                    <span>编辑</span>
                                                </a>
                                               <form style="display: inline" action="{{ route('attributes.destroy',[$attr->id,$attr->type_id]) }}" method="post">
                                                    {{csrf_field()}}
                                                    {{method_field('DELETE')}}
                                                    <button type="submit" class="btn bg-red btn-xs ">
                                                     <i class="material-icons">delete</i>
                                                        <span>删除</span>
                                                       
                                                    </button>
                                                </form>
                                            </td>
                                        </tr>

                                    @endforeach

                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <!-- #END# Basic Table -->
     </div>


@endsection

@section('js-script')
	{{-- expr --}}
    <!-- JQuery DataTable Css -->
    <link href="{{ asset('admin/plugins/jquery-datatable/skin/bootstrap/css/dataTables.bootstrap.css') }}" rel="stylesheet">

	<!-- Jquery Core Js -->
    <script src="{{ asset('admin/plugins/jquery/jquery.min.js') }}"></script>

    <!-- Bootstrap Core Js -->
    <script src="{{ asset('admin/plugins/bootstrap/js/bootstrap.js') }}"></script>

    <!-- Select Plugin Js -->
    <script src="{{ asset('admin/plugins/bootstrap-select/js/bootstrap-select.js') }}"></script>
    <script src="{{ asset('admin/plugins/sweetalert/sweetalert.min.js') }}"></script>


    <!-- Slimscroll Plugin Js -->
    <script src="{{ asset('admin/plugins/jquery-slimscroll/jquery.slimscroll.js') }}"></script>

    <!-- Waves Effect Plugin Js -->
    <script src="{{ asset('admin/plugins/node-waves/waves.js') }}"></script>

   <!-- Jquery DataTable Plugin Js -->
    <script src="{{ asset('admin/plugins/jquery-datatable/jquery.dataTables.js') }}"></script>
    <script src="{{ asset('admin/plugins/jquery-datatable/skin/bootstrap/js/dataTables.bootstrap.js') }}"></script>
    <script src="{{ asset('admin/plugins/jquery-datatable/extensions/export/dataTables.buttons.min.js') }}"></script>
    <script src="{{ asset('admin/plugins/jquery-datatable/extensions/export/buttons.flash.min.js') }}"></script>
    <script src="{{ asset('admin/plugins/jquery-datatable/extensions/export/jszip.min.js') }}"></script>
    <script src="{{ asset('admin/plugins/jquery-datatable/extensions/export/pdfmake.min.js') }}"></script>
    <script src="{{ asset('admin/plugins/jquery-datatable/extensions/export/vfs_fonts.js') }}"></script>
    <script src="{{ asset('admin/plugins/jquery-datatable/extensions/export/buttons.html5.min.js') }}"></script>
    <script src="{{ asset('admin/plugins/jquery-datatable/extensions/export/buttons.print.min.js') }}"></script>
    @if(session('success'))
    <script>
                swal("{{session('success')}}", "", "success");
                    
                </script>
    @endif

    <!-- Custom Js -->
    <script src="{{ asset('admin/js/admin.js') }}"></script>

    <script src="{{ asset('admin/js/pages/tables/jquery-datatable.js')}}"></script>

    <!-- Demo Js -->
    <script src="{{ asset('admin/js/demo.js') }}"></script>  
@endsection